package cn.itrip.auth.service;

import com.cloopen.rest.sdk.CCPRestSmsSDK;
import org.springframework.stereotype.Service;

import java.util.HashMap;



@Service("smsService")
public class SmsServiceimpl implements  SmsService{

    @Override
    public void send(String to, String templateId, String[] datas) throws Exception {
        CCPRestSmsSDK sdk=new CCPRestSmsSDK();
        sdk.init("app.cloopen.com","8883");
        sdk.setAccount("8a216da8686f00af016870ed7c3501b4","ce41e3f7bd7a46aa975adf1aec9005d9");
        sdk.setAppId("8a216da8686f00af016870ed7c9001ba");
        HashMap resulte = sdk.sendTemplateSMS(to, templateId, datas);
        //判断是否发送成功
        if("000000".equals(resulte.get("statusCode"))){
          System.out.print("短信发送成功");
        }else{
            throw new Exception(resulte.get("statusCode").toString()+":"+resulte.get("statusMsg").toString());
        }

    }
}
